//
//  ChangePSDViewController.m
//  ROSE
//
//  Created by 艾阳 on 2018/6/4.
//  Copyright © 2018年 HeNanZhongDunYunAn. All rights reserved.
//

#import "ChangePSDViewController.h"
#import "ThreeInputView.h"

@interface ChangePSDViewController ()

@property (nonatomic,strong) UIButton *sureButton;
@property (nonatomic,strong) ThreeInputView *inputView;

@end

@implementation ChangePSDViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    self.title = @"修改密码";
    self.inputView = [[ThreeInputView alloc]init];
    [self.inputView setTitle:@[@"旧密码",@"新密码",@"确认新密码"] PlaceHolder:@[@"6-14英文数字和下划线组合",@"6-14英文数字和下划线组合",@"6-14英文数字和下划线组合"]];
    self.inputView.textField2.secureTextEntry = YES;
    self.inputView.textField3.secureTextEntry = YES;
    [self.view addSubview:self.inputView];
    [self.inputView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(20);
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(0);
        make.height.mas_equalTo(300);
    }];
    [self setSureBtn];
    
}
- (void)setSureBtn{
    UIButton *sureBtn = [[UIButton alloc]init];
    sureBtn.backgroundColor = [UIColor themeColor];
    sureBtn.titleLabel.textColor = [UIColor whiteColor];
    [sureBtn setTitle:@"确认" forState:UIControlStateNormal];
    [sureBtn.titleLabel setFont:[UIFont systemFontOfSize:15]];
    sureBtn.layer.masksToBounds = YES;
    sureBtn.layer.cornerRadius = 20.0f;
    [sureBtn addTarget:self action:@selector(changePSD) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:sureBtn];
    
    [sureBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(35);
        make.right.mas_equalTo(-35);
        make.bottom.mas_equalTo(-20);
        make.height.mas_equalTo(40);
    }];
}

/**
 确认修改密码
 */
- (void)changePSD{
    if ([self.inputView validateInput]) {
        [[LMJRequestManager sharedManager] POST:[NSString stringWithFormat:@"%@/usercenter/editpassword",url_base] parameters:@{@"OLDPASSWORD":self.inputView.textField1.text,@"NEWPASSWORD":self.inputView.textField3.text} completion:^(LMJBaseResponse *response) {
            if (response.error==nil&&[response.responseObject[@"errorcode"] isEqualToString:@"000000"]) {
                /** 修改成功--重新登录*/
            }
        }];
    }else{
        /** 输入错误**/
    }
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
